      var DOCLIST_SCOPE = 'https://picasaweb.google.com/data';
      var DOCLIST_FEED = DOCLIST_SCOPE + '/entry/api/user/default';
      var photos = {}; // In memory cache for the user's entire doclist.
      var selectedPhotos = {};
      var tags = {}; // In memory cache for the user's entire doclist.
      var selectedTags = {};
      var requests = [];
      var userId;
      var albumId;
      var photoId;

      var oauth = ChromeExOAuth.initBackgroundPage({
        'request_url': 'https://www.google.com/accounts/OAuthGetRequestToken',
        'authorize_url': 'https://www.google.com/accounts/OAuthAuthorizeToken',
        'access_url': 'https://www.google.com/accounts/OAuthGetAccessToken',
        'consumer_key': 'anonymous',
        'consumer_secret': 'anonymous',
        'scope': DOCLIST_SCOPE,
        'app_name': 'Chrome Extension Sample - Accessing Picasa with OAuth'
      });


      function clearPendingRequests() {
        for (var i = 0, req; req = requests[i]; ++i) {
          window.clearTimeout(req);
        }
        requests = [];
      };

      function logout() {
        docs = [];
        oauth.clearTokens();
        clearPendingRequests();
      };


chrome.tabs.onActivated.addListener(function (actTab) {
chrome.tabs.get(actTab.tabId, function (tab) {
    var urlParts;
//g+
    if(tab.url.indexOf("plus.google.com") > 0) {
	urlParts = tab.url.split('?')[0].split('/');
	userId = urlParts[4];
	albumId = urlParts[6];
        tabId = tab.id;
//picasaweb
    } else if (tab.url.indexOf("picasaweb.google.com/lh/reorder") > 0 ){
	urlParts = tab.url.split('?')[1].split('&');
	userId = urlParts[0].split('=')[1];
	albumId = urlParts[1].split('=')[1];
        tabId = tab.id;
    } else if (tab.url.indexOf("picasaweb.google.com") > 0 && tab.url.indexOf("#") > 0) {
	urlParts = tab.url.split('?')[0].split('/');
	userId = urlParts[3];
	photoId = tabs.url.split('#').length > 0 ? tabs.url.split('#')[1] : null;
        tabId = tab.id;
    }
});
});

chrome.contextMenus.create({"title": "Tag Photo",
                            "id": "TagPhotoMenuId", 
                            "contexts":["all"],
                            "documentUrlPatterns":["https://plus.google.com/photos/*", "https://picasaweb.google.com/lh/reorder*"]});

function onClickHandler(info, tab) {
  if (info.menuItemId == "TagPhotoMenuId") {
    chrome.windows.create({ url: 'info.html', width: 520, height: 660 });
  }
};

chrome.contextMenus.onClicked.addListener(onClickHandler);
